import { CategoryType } from "@/types/course";
import request from "../utils/request";

export const categoryGet = () => {
  return request.get("/classes/ReactCategory");
};

export const categoryPost = (category: CategoryType) => {
  return request.post("/classes/ReactCategory", category);
};
interface CourseParmsType {
  name?: { $regex: string; $options: "i" };
  isvip?: string;
}
export const courseGet = ({ name, isvip }: { name: string; isvip: string }) => {
  let where = {} as CourseParmsType;
  if (name) {
    where.name = { $regex: name, $options: "i" };
  }
  if (isvip && isvip != "1") {
    where.isvip = isvip + "";
  }
  return request.get("/classes/ReactCourse", {
    params: {
      where,
    },
  });
};
